import Header from './components/Header';
import Slider from './components/Slider';
import styles from './index.less';
import { getCookie } from '@/utils/cookie';
import MallHeader from './mall_components/Header';
import Main from './mall_components/Main';
import KoDingIndex from './koding_components/index';

const Layout = ({ children, location: { pathname } }: any) => {
  const { username } = getCookie();

  const renderIndex: (username: string) => JSX.Element = (username) => {
    switch (username) {
      case 'admin':
        return (
          <div
            className={styles.layout}
            data-show-header={true}
            data-show-menu={true}
            data-pathname={pathname}
          >
            <Header />
            <Slider />
            {children}
          </div>
        );
      case 'koding':
        return (
          <>
            <KoDingIndex />
            {children}
          </>
        );
      default:
        return (
          <>
            <MallHeader />
            <Main />
          </>
        );
    }
  };

  return renderIndex(username);
};

export default Layout;
